package org.dreamwork.tools.jfx;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import org.dreamwork.tools.LocalUtil;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

public class FXSplash extends Application {
    private static Long taskId;
    private static Stage stage;
    @Override
    public void start (Stage stage) throws IOException {
        FXSplash.stage = stage;
        FXMLLoader loader = new FXMLLoader (getClass ().getClassLoader ().getResource ("splash.fxml"));
        Parent root = loader.load ();
        Scene scene = new Scene (root);
        stage.setScene (scene);
        stage.initStyle (StageStyle.UNDECORATED);
//        stage.setAlwaysOnTop (true);

        stage.show ();
//        taskId = LocalUtil.schedule (()-> Platform.runLater (stage::hide), 10, TimeUnit.SECONDS);
    }

    public static void close () {
/*
        if (stage != null) {
            Platform.runLater (()->stage.hide ());
            if (taskId != null) {
                LocalUtil.cancelTask (taskId);
            }
        }
*/
    }
}